<?php

namespace app\model;

class RoleModel extends BaseModel
{
    protected $table = 'role';

    const STATUS = 1;

    const UN_STATUS = 2;

    /**
     * @return false|\PDOStatement|string|\think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public static function getRoleInfo()
    {
        $where = [
            'status' =>self::STATUS,
            'deleted' =>self::DELETED,
        ];
        return self::where($where)->field(['id','name'])->select();
    }




    public function getRolePge($page,$pageSize,$condition=[],$is_count = false,$order=''){
        $join=[
//            ['bankinfo bank','bank.bank_id=role.bank_id','LEFT'],
        ];

        $this->alias('role')
            ->field('role.*')
            ->join($join);
        if($condition){
            $this->where($condition);
        }
        if($order){
            $this->order($order);
        }
        if($is_count){
            return $this->count();
        }
        return $this->page($page,$pageSize)->select();
    }

    public function getRoleList($condition=[],$order='',$limit=''){
        $join=[
//            ['bank bank','bank.bank_id=role.bank_id','LEFT'],
        ];

        $this->alias('role')
            ->field('role.*')
            ->join($join);
        if($condition){
            $this->where($condition);
        }
        if($order){
            $this->order($order);
        }
        if($limit){
            $this->limit($limit);
        }
        return $this->select();
    }
}